package com.jy.api;

import io.restassured.RestAssured;
import org.junit.Before;
import org.junit.Test;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.notNullValue;

/**
 * Created by hanxi on 2017/8/16.
 */

public class LoginIT {
    @Before
    public void setup() {
        RestAssured.baseURI = "http://localhost";
        RestAssured.port = 8080;
    }

    @Test
    public void given_correctCredential_when_loginAdmin_then_returnTokenAndOk() {
        given().auth().preemptive().basic("15308039727", "123456").
                when().post("/v1/admin/login").
                then().statusCode(200)
                .header("x-auth-token", notNullValue());
    }

    @Test
    public void given_emptyCredential_when_loginAdmin_then_returnUnauthorized() {
        given().when().post("/v1/admin/login").then().log().all().statusCode(401);
    }

    @Test
    public void given_optionsRequest_when_login_then_returnOk() {
        given().when().options("/v1/pos/login").then().statusCode(200);
    }







}
